package com.opensource.afuluo.valve.stage.exec;

import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import cn.hutool.http.Method;
import com.opensource.afuluo.annotation.AtomicValve;
import com.opensource.afuluo.ctx.Context;
import com.opensource.afuluo.valve.Valve;

@AtomicValve("EXEC_HTTP_PROTOCOL")
public class HttpProtocolExecutorValve implements Valve {

    @Override
    public void fire(Context ctx) {
        HttpRequest request = HttpUtil.createRequest(Method.GET, "https://www.baidu.com/");
        HttpResponse response = request.execute(false);
        ctx.setConfig(HttpResponse.class, response);
    }
}
